#pragma once

#include<pthread.h>
//#include<cstdlib>
#include<iostream>

class myMutex
{
public:
    myMutex(pthread_mutex_t* PMutex)
    :_pMutex(PMutex)
    {
        pthread_mutex_init(_pMutex,nullptr);
    }
    ~myMutex()
    {
        pthread_mutex_destroy(_pMutex);
    }
    void lock()
    {
        pthread_mutex_lock(_pMutex);
    }
    void unlock()
    {
        pthread_mutex_unlock(_pMutex);
    }


private:
    pthread_mutex_t* _pMutex;
};

class myLockGuard
{
public:
    myLockGuard(pthread_mutex_t* mutex)
    :_mutex(mutex)
    {
        _mutex.lock();
    }
    ~myLockGuard()
    {
        _mutex.unlock();
    }
private:
    myMutex _mutex;

};